<template>
	<view class="fui-wrap">
		<fui-list>
			<fui-list-cell v-for="(item,index) in list" arrow :key="index" @click="goParking(item)">
				<view class="line">
					<fui-text :text="item.parking.title" type="black" size="32" block fontWeight="bolder"></fui-text>
					<view style="margin-top: 20rpx;display: flex;justify-content: space-between;">
						<fui-text :text="`总收入：${item.pay_price || 0}`" type="black" size="28" block></fui-text>
						<fui-text :text="`费率：${item.persent}‰`" type="black" size="28" block></fui-text>
					</view>
				</view>
			</fui-list-cell>
		</fui-list>
		<fui-empty v-if="list.length===0" :src="`${baseUrl}assets/img/miniapp/empty.png`" title="暂无数据!" :marginTop="200"></fui-empty>
	</view>
</template>

<script>
	import {methods,baseUrl} from '@/utils/core.js';
	export default {
		data() {
			return {
				baseUrl:baseUrl,
				list:[],
				page:1,
				endData:false,
			}
		},
		onLoad(e) {
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		onPullDownRefresh() {
			this.list=[];
			this.page=1;
			this.endData=false;
			this.getList(function(){
				uni.stopPullDownRefresh();
			});
		},
		methods: {
			...methods,
			getList:function(callback=false){
				if(this.endData){
					this.$msg('已经到底了');
					return;
				}
				this.$get('daili/park',{
					page:this.page
				},true).then(res=>{
					this.list=this.list.concat(res);
					this.page++;
					if(res.length<10){
						this.endData=true;
					}	
					if(callback){
						callback();
					}
				}).catch(e=>{
					this.err=e.msg;
				});
			},
			goParking:function(e){
				this.$navigateTo('daili/log?type=0&parking_id='+e.parking_id)
			}
		}
	}
</script>

<style lang="scss" scoped>
.line{
	width: 80%;
}
</style>